package com.coursehub.user.dto;

import com.coursehub.user.entity.User;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 登录响应DTO
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class LoginResponseDto {
    
    /**
     * JWT token
     */
    private String token;
    
    /**
     * token类型
     */
    private String tokenType = "Bearer";
    
    /**
     * 用户信息
     */
    private UserInfoDto userInfo;
    
    public LoginResponseDto(String token, User user) {
        this.token = token;
        this.userInfo = new UserInfoDto(user.getUserId(), user.getUserName(), user.getUserAccount());
    }
    
    /**
     * 用户信息内部类
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class UserInfoDto {
        private String userId;
        private String userName;
        private String userAccount;
    }
}